package com.example.produceexample.service;

import com.example.common.QueueConsts;
import com.example.common.UserEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 生产服务.
 *
 * @author Luo
 * @version 3.7.0
 * @date 2021/6/24 19:12
 **/
@Slf4j
@Service
public class ProduceService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 推送用户消息.
     *
     * @param userEvent 用户事件
     */
    public void sendUserEvent(UserEvent userEvent) {
        log.info("推送用户消息：{}", userEvent);
        rabbitTemplate.convertAndSend(QueueConsts.USER_QUEUE_NAME, userEvent);
    }

}

